package com.xfxplus.m.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.xfxplus.m.Components.DaggerMainComponents;
import com.xfxplus.m.Components.DaggerNetComponents;
import com.xfxplus.m.Module.MainModule;
import com.xfxplus.m.Module.Order_adapter;
import com.xfxplus.m.R;
import com.xfxplus.m.dataBean.Userbean;
import com.xfxplus.m.presenter.TestA1;
import com.xfxplus.m.presenter.TestA1.Tint;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;


import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;

public class MainActivity extends AppCompatActivity implements Tint ,View.OnClickListener{



    TextView tex;
    Button button;
    RecyclerView recyclerView;

    @Inject
    TestA1 testA1;

    @Inject
    Order_adapter order_adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        DaggerMainComponents.builder().netComponents(DaggerNetComponents.create()).mainModule(new MainModule(this,this)).build().in(this);
        tex=findViewById(R.id.textv);
        button=findViewById(R.id.button);
        recyclerView=findViewById(R.id.recycler);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(order_adapter);
        button.setOnClickListener(this);
        tex.setOnClickListener(this);

    }

    @Override
    public void UpdateUI() {

        Toast.makeText(this,"啦啦啦a11",Toast.LENGTH_SHORT).show();
        List<Userbean> userbeanList=new ArrayList<>();
        for (int i=10;i<20;i++){
            userbeanList.add(new Userbean(i+"a11aa","bbbb"));
        }
        order_adapter.reDate(userbeanList);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.textv:
                Intent intentu = new Intent(this, MyWebActivity.class);
                intentu.setFlags(FLAG_ACTIVITY_CLEAR_TOP );
                startActivity(intentu);
                break;
            case R.id.button:
                testA1.getDato();
                break;
        }
    }
}

